 ///
 /// @file    Point3d.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-03-12 11:14:19
 ///
 
#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
	Point(int ix = 0, int iy = 0)
	: _ix(ix)
	, _iy(iy)
	{
		cout << "Point(int,int)" << endl;
	}

	void disp()
	{
		cout << "(" << _ix
			 << "," << _iy
			 << ")" << endl;
	}
	int getX()const
	{	return _ix;	}
protected:
	int getY()const
	{	return _iy;	}
private:
	int _ix;
protected:
	int _iy;
};

class Point3D : public Point
{
public:
	Point3D(int x, int y, int z)
	: Point(x, y)
	, _iz(z)
	{
		cout << "Point3D(int,int,int)" << endl;
	}

	void display()
	{
		cout << "(" << getX() 
			 << "," << _iy //在子类内部访问父类的非私有成员(允许)
			 << "," << _iz
			 << ")" << endl;
	}

	int calcSum()
	{
		return getX() + getY() + _iz;
	}
private:
	int _iz;
};

int main(void)
{
	Point pt1(7, 8);
	pt1.disp();

	Point3D pt2(3, 4, 5);
	pt2.display();
	//pt2.getY();//子类对象无法访问父类的非public的成员
				 //只有public成员能够访问,前提条件是:public继承
	cout << "position x:" << pt2.getX() << endl;

	cout << pt2.calcSum() << endl;
	
}
